=begin
元编程
=end

# 开放类
class NilClass
  def blank?
    true
  end
end

class String
  def blank?
    self.size == 0
  end
end

puts ["", "aaa", nil].select { |x| !x.blank?}

# method_missing
class Roman
  def self.method_missing name, *args
    roman = name.to_s
    roman.gsub!("IV", "IIII")
    roman.gsub!("IX", "VIIII")
    roman.gsub!("XL", "XXXX")
    roman.gsub!("XC", "LXXXX")

    (roman.count("I") +
    roman.count("V") * 5 +
    roman.count("X") * 10 +
    roman.count("L") * 50 +
    roman.count("C") * 100)
  end
end

puts Roman.X
puts Roman.XX
